package com.server;

import com.annotation.GrpcService;
import com.meta.HtMetaInfoSyncServiceGrpc;
import com.meta.HtMetaSyncRequest;
import com.meta.HtMetaSyncResponse;
import com.meta.SyncType;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 何永豪
 * @className HtMetaSyncService
 * @description TODO
 * @date 2023/11/6 15:25
 */
@Slf4j
@GrpcService
public class HtMetaSyncService extends HtMetaInfoSyncServiceGrpc.HtMetaInfoSyncServiceImplBase {

    @Override
    public void syncMeta(HtMetaSyncRequest request, StreamObserver<HtMetaSyncResponse> responseObserver) {
        String syncJson = request.getSyncJson();
        log.info("接收到json：{}",syncJson);
        SyncType syncType = request.getSyncType();
        int number = syncType.getNumber();
        log.info("同步类型：{}",number);
        HtMetaSyncResponse syncResponse = HtMetaSyncResponse.newBuilder()
                .setCode("1000")
                .setMsg("同步成功").build();
        responseObserver.onNext(syncResponse);
        responseObserver.onCompleted();
    }

}
